package semantic.model;


public class PrimaryExpressionNode {
	
	private ExpressionNode expNode;
	
	private PropertyCallNode propertyCallNode;
	
	public PrimaryExpressionNode(ExpressionNode expNode, PropertyCallNode propertyCallNode) {
		this.expNode = expNode;
		this.propertyCallNode = propertyCallNode;
	}
	
	public String toString() {
		return "[PrimaryExpressionNode(expNode=" + expNode + ", propertyCallNode=" + propertyCallNode + ")]";
	}

	public ExpressionNode getExpressionNode() {
		return this.expNode;
	}
	
	public PropertyCallNode getPropertyCallNode() {
		return this.propertyCallNode;
	}
	
	public String getValue() throws Exception{
		if((expNode != null)&&(propertyCallNode != null)){
			if(expNode instanceof UndefinedExpressionNode){
				return propertyCallNode.getValue();
			}else{
				//aqui � o caso que a gente nao conseguia se lembrar
				//delz nos ajude!!!!!!!!!!
				throw new Exception("Can't get value!");
			}
			
		}
		if(expNode != null){
			return expNode.getValue();
		}
		return propertyCallNode.getValue();
	}

}
